<html>
<body>

<p>
<?php
echo "Hello World"; 
echo "Good-Bye World";
?>
</p>

<p>
<?php
$text = "Variable test";
$x = 5;
$y = 10;
$z = null;

	function myAdd()
		{
			global $x,$y,$z;
			$z = $x + $y;
		}
myAdd();
print $z;
echo $text;
echo $text . "" . $x . "" . $y;
?>
</p>

<p>
<?php
echo strlen("Jerk!");
?>

<p>
<?php
$d = date("D");

	if ($d == "Mon") 
		{
		echo ("Sucks for you!");
		}
	else
		{
		echo ("Could be worse");
		}
?>
</p>

<p>
<?php
$x="text";
switch ($x)
{
case "text":
  echo "Number 1";
  break;
case 2:
  echo "Number 2";
  break;
case 3:
  echo "Number 3";
  break;
default:
  echo "No number between 1 and 3";
}
?>
</p>

<p>
<?php
$cars[0]="Saab";
$cars[1]="Volvo";
$cars[2]="BMW";
$cars[3]="Toyota";
echo $cars[0] . " and " . $cars[1] . " are Swedish cars.";
?> 
</p>

<p>
<?php
$ages['Peter'] = "32";
$ages['Quagmire'] = "30";
$ages['Joe'] = "34";

echo "Peter is " . $ages['Peter'] . " years old.";
?> 
</p>

<p>
<form action="welcome.php" method="get">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form> 
</p>

<p> MySql
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_db", $con);
mysql_query("DELETE FROM Persons");

// Create table
mysql_select_db("my_db", $con);
$sql = "CREATE TABLE Persons
(
FirstName varchar(15),
LastName varchar(15),
Age int
)";

// Execute query
mysql_query($sql,$con);

//Inserting data

mysql_select_db("my_db", $con);

mysql_query("INSERT INTO Persons (FirstName, LastName, Age)
VALUES ('Peter', 'Griffin',35)");

mysql_query("INSERT INTO Persons (FirstName, LastName, Age)
VALUES ('Glenn', 'Quagmire',33)");

mysql_select_db("my_db", $con);

$result = mysql_query("SELECT * FROM Persons");

while($row = mysql_fetch_array($result))
  {
  echo $row['FirstName'] . " " . $row['LastName'];
  echo "<br />";
  }

mysql_close($con);
?>
</p>

</body>
</html> 














